from django.db import models

from django.db import models


from __future__ import unicode_literals

from django.db import models
from django.core.urlresolvers import reverse


class Tag(models.Model):
    tag_name = models.CharField(max_length=64)

    def __unicode__(self):
        return self.tag_name


# Create your models here.
class Article(models.Model):
    title = models.CharField(max_length=100)  # 博客题目 CharField 用于存储字符串, max_length设置最大长度
    category = models.CharField(max_length=50, blank=True)  # 博客标签文章内容
    date_time = models.DateTimeField(auto_now_add=True)  # 博客日期
    content = models.TextField(blank=True, null=True)  #

    def get_absolute_url(self):
        path = reverse('detail', kwargs={'id': self.id})
        return "http://127.0.0.1:8000%s" % path
  #  @property
    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['-date_time']